package com.shamine.kuaiqiao.blink.tools

import cn.bmob.v3.datatype.BmobDate
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*

open class DateTool {
    fun stringToDate(timeString: String): Date{
        val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
        return format.parse(timeString)
    }

    /**
     * 时间字符串转换为BmobDate
     * @param time
     * @return
     */
    fun getBmobDate(time: String): BmobDate {
        var date: Date? = null
        val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
        try {
            date = sdf.parse(time)
        } catch (e: ParseException) {
            e.printStackTrace()
        }
        return BmobDate(date)
    }
}